//
//  VideoFrameBufferPool.h
//  MediaStreamer
//
//  Created by Think on 16/2/14.
//  Copyright © 2016年 Cell. All rights reserved.
//

#ifndef __MediaStreamer__VideoFrameBufferPool__
#define __MediaStreamer__VideoFrameBufferPool__

#include <vector>
#include <pthread.h>

#include "MediaDataType.h"

#define VIDEOFRAME_BUFFER_NUM 4

using namespace std;

namespace MediaData {

class VideoFrameBufferPool
{
public:
    VideoFrameBufferPool();
    VideoFrameBufferPool(int videoWidth, int videoHeight);
    ~VideoFrameBufferPool();

    bool push(MediaStreamer::VideoFrame *videoFrame);
    MediaStreamer::VideoFrame* front();
    void pop();

    void flush();
private:
    pthread_mutex_t mLock;
    vector<MediaStreamer::VideoFrame*> mVideoFrameBuffers;
    
    int write_pos;
    int read_pos;
    int buffer_num;
    
    int videoFrameSize;
};
}

#endif /* defined(__MediaStreamer__VideoFrameBufferPool__) */
